package org.flint92.springcloud.feign.controller;

import org.flint92.user.domain.User;
import org.flint92.user.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author flint92
 */
@RestController
@RequestMapping("/feign")
public class UserController {

    private final Logger logger = LoggerFactory.getLogger(UserController.class);

    private final UserService userService;

    @Autowired
    public UserController(UserService userService) {
        this.userService = userService;
    }

    @PostMapping("/user/save")
    public boolean save(@RequestBody User user) {
        return userService.saveUser(user);
    }

    @GetMapping("/user/list")
    public List<User> findAll() {
        return userService.findAll();
    }

}
